package com.xkdx.guangguang.fragment.my.setup;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.xkdx.guangguang.module.network.AbsModule;

public class ExchangeListModule extends AbsModule {
	List<MyExchange> list;

	@Override
	public void parseData() throws Exception {

		backJson = (JSONArray) result;
		try {
			for (int i = 0; i < backJson.length(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("payListGet")) {
					list = parserExchangeInfo(jsonObj
							.getJSONObject("DetailInfo"));
				}

			}
		} catch (Exception e) {
			throw e;
		}

	}

	private List<MyExchange> parserExchangeInfo(JSONObject person)
			throws Exception {
		List<MyExchange> ls = new ArrayList<MyExchange>();
		if (person == null) {
			return null;
		}
		if (!person.getString("StatusCode").equals("1")) {
			return ls;
		} else {
			try {
				JSONArray stut = (JSONArray) person.get("DetailInfo");
				if (!stut.equals("")) {
					for (int j = 0; j < stut.length(); j++) {
						MyExchange exchange = new MyExchange();
						JSONObject pic = (JSONObject) stut.opt(j);
						exchange.setProduct_Name(pic.getString("Product_Name"));
						exchange.setLogo(pic.getString("Logo"));
						exchange.setEnd_Date(pic.getString("End_Date"));
						exchange.setSuccess(pic.getString("Success"));
						exchange.setType(pic.getString("Type"));
						exchange.setExchangeCode(pic.getString("Exchange_Code"));
						exchange.setExchange_Time(pic
								.getString("Exchange_Time"));
						exchange.setState(pic.getString("State"));
						exchange.setPayUrl(pic.getString("PayUrl"));
						ls.add(exchange);
					}
					return ls;
				}

			} catch (Exception e) {
				throw e;
			}
		}
		return ls;
	}

	public class MyExchange {
		private String Product_Name;
		private String Exchange_Time;
		private String Type;
		private String Success;
		private String PayUrl;
		private String Logo;
		private String State;
		private String ExchangeCode;
		private String End_Date;

		public String getEnd_Date() {
			return End_Date;
		}

		public void setEnd_Date(String end_Date) {
			End_Date = end_Date;
		}

		public String getProduct_Name() {
			return Product_Name;
		}

		public void setProduct_Name(String product_Name) {
			Product_Name = product_Name;
		}

		public String getExchange_Time() {
			return Exchange_Time;
		}

		public void setExchange_Time(String exchange_Time) {
			Exchange_Time = exchange_Time;
		}

		public String getType() {
			return Type;
		}

		public void setType(String type) {
			Type = type;
		}

		public String getSuccess() {
			return Success;
		}

		public void setSuccess(String success) {
			Success = success;
		}

		public String getPayUrl() {
			return PayUrl;
		}

		public void setPayUrl(String payUrl) {
			PayUrl = payUrl;
		}

		public String getLogo() {
			return Logo;
		}

		public void setLogo(String logo) {
			Logo = logo;
		}

		public String getState() {
			return State;
		}

		public void setState(String state) {
			State = state;
		}

		public String getExchangeCode() {
			return ExchangeCode;
		}

		public void setExchangeCode(String exchangeCode) {
			ExchangeCode = exchangeCode;
		}

	}

}
